def _impl(ctx):
    print("rule全称=", ctx.label)
    output_file = ctx.outputs.output_name
    print("输出压缩文件: ", output_file)

    # zip命令的用法
    # $ zip main.zip readme.md main.cpp libthread.so
    args = ctx.actions.args()
    args.add(output_file)
    args.add_all(ctx.files.input_list)
    print("zip命令:", args)
    print(type(args))

    ctx.actions.run(
        executable = "/usr/bin/zip",
        arguments = [
            args,
        ],
        inputs = ctx.files.input_list,
        # inputs = [
        #     ctx.files.input_list[1],
        # ],
        outputs = [
            output_file,
        ],
    )

    return DefaultInfo(
        files = depset([
            output_file,
        ]),
    )

zip_archive = rule(
    implementation = _impl,
    attrs = {
        "input_list": attr.label_list(allow_files = True, mandatory = True),
        "output_name": attr.output(mandatory = True),
    },
)
